import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from "../views/Home.vue"
import Cart from "../views/Cart.vue"
import Kinds from "../views/Kinds.vue"
import Mine from "../views/Mine.vue"
import Error from "../views/Error.vue"
import Detail from "../views/Detail.vue"
import MyFooter from "../components/Footer/MyFooter"
import Login from "../views/Login.vue"
import Register from "../views/Register/Register"
import Reg1 from "../views/Register/Reg1"
import Reg2 from "../views/Register/Reg2"
import Reg3 from "../views/Register/Reg3"
import KindsGoods from "../views/KindsGoods"
import Search from "../views/Search"
import Order from "../views/Order"
import Pay from "../views/Pay"
import Massage from "../views/Massage/Massage"
import AddMassage from "../views/Massage/AddMassage"
import SetMassage from "../views/Massage/SetMassage"
import Payed from "../views/Payed"
import AllOrder from "../views/AllOrder"

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    components: {
      default: Home,
      MyFooter: MyFooter//键名和键值一样的情况下可以只写一个
    }
  },
  {
    path: '/kinds',
    name: 'Kinds',
    components: {
      default: Kinds,//显示两个组件
      MyFooter: MyFooter//显示两个组件
    },
  },
  {
    path: '/kindsgoods/:category/:brand',
    name: 'KindsGoods',
    component: KindsGoods
  },
  {
    path: '/search/:kindValue',
    name: 'Search',
    component: Search
  },
  {
    path: '/cart',
    name: 'Cart',
    components: {
      default: Cart,
      MyFooter: MyFooter
    }
  },
  {
    path: '/order/:time',
    name: 'Order',
    component: Order
  },
  {
    path: '/allorder',
    name: 'AllOrder',
    component: AllOrder
  },
  {
    path: '/pay/:price',
    name: 'Pay',
    component: Pay
  },
  {
    path: '/payed',
    name: 'Payed',
    component: Payed
  },
  {
    path: '/massage',
    name: 'Massage',
    component: Massage
  },
  {
    path: '/addmassage',
    name: 'AddMassage',
    component: AddMassage
  },
  {
    path: '/setmassage/:massagecard',
    name: 'SetMassage',
    component: SetMassage
  },
  {
    path: '/mine',
    name: 'Mine',
    components: {
      default: Mine,
      MyFooter: MyFooter
    }
  },
  {
    path: '/detail/:proid',
    name: 'Detail',
    component: Detail
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/register',
    name: 'Register',
    component: Register,
    redirect: '/register/reg1',//重定项的另一种写法
    children: [
      // {
      //   path: '/register',
      //   redirect: 'Reg1'
      // },
      {
        path: '/register/reg1',
        name: 'Reg1',
        component: Reg1
      }, {
        path: '/register/reg2',
        name: 'Reg2',
        component: Reg2
      }, {
        path: '/register/reg3',
        name: 'Reg3',
        component: Reg3,
      }
    ]
  },
  {
    path: '*',//不是路由规则中的路由时，出现这个页面
    name: "Error",
    component: Error
  }
]

const router = new VueRouter({
  routes
})

export default router
